package com.briup.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.briup.common.bean.TblArticle;
import com.briup.common.bean.TblCustomer;
import com.briup.common.dao.TblArticleMapper;
import com.briup.common.dao.TblCategoryMapper;
import com.briup.common.dao.TblCustomerMapper;
import com.briup.service.interfaces.TblArticleService;

import oracle.sql.OPAQUE;


public class TblArticleServiceImpl implements TblArticleService{

	@Override
	public List<TblArticle> selectArticlesByTitle(SqlSession openSession, String title) {
		List<TblArticle> articles = null ;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		articles = mapper.selectArticlesByTitle(title) ;
		return articles ;
	}

	@Override
	public List<TblArticle> selectArticlesByAuthor(SqlSession openSession, String author) {
		List<TblArticle> articles = null ;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		articles = mapper.selectArticlesByAuthor(author) ;
		return articles ;
	}

	@Override
	public List<TblArticle> selectArticlesByCategoryName(SqlSession openSession, String CategoryName) {
		List<TblArticle> articles = null ;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		articles = mapper.selectArticlesByCategoryName(CategoryName) ;
		return articles ;
	}
	@Override
	public int insertArticleByArticle(SqlSession openSession, TblArticle article) {
		int i=0;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		i= mapper.insertArticleByArticle(article) ;
		return i;
	}

	@Override
	public int updateArticleClickTimesByid(SqlSession openSession, String id, int clickTimes) {
		int i=0;
		TblArticleMapper mapper=openSession.getMapper(TblArticleMapper.class);
		i=mapper.updateArticleClickTimesByid(id, clickTimes);
		return i;
	}

	@Override
	public List<TblArticle> selectArticles(SqlSession openSession) {
		List<TblArticle> articles = null ;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		articles = mapper.selectArticles() ;
		return articles ;
	}

	@Override
	public int deleteArticleById(SqlSession openSession, String id) {
		int i = 0 ;
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		i = mapper.deleteArticleById(id) ;
		return i ;
	}

	@Override
	public int updateArtcleByArticle(SqlSession openSession, TblArticle article) {
		int i = 0 ; 
		TblArticleMapper mapper = openSession.getMapper(TblArticleMapper.class) ;
		i = mapper.updateArtcleByArticle(article) ;
		return i ;
	}

}
